import http from "@/utils/http";
import type { searchAllFieldData } from "@/apis";

/**
 * 搜索所有表单字段
 */
export const searchAllField = (keywords: string) => {
  return http.get<searchAllFieldData[]>("/process/model/field/search", { keywords });
};

/**
 * 待办——查询流程模型
 * @param { string } formId -表单ID
 * @param { string } businessKey -业务id
 */
export const pendingProcessModel = (formId: string, businessKey: string) => {
  return http.get(`/process/model/detail/${formId}/${businessKey}`);
};

/**
 * 获取流程模型实例数据
 * @param { string } instanceId -表单实例ID
 */
export const processInstanceForm = (instanceId: string | undefined) => {
  return http.get(`/process/form/limitData/by/${instanceId}`);
};

/**
 * 办理CRM流程任务
 * @param { string } commTaskId -任务ID
 * @param data
 */
export const taskCrmComplete = (commTaskId: string, data: any) => {
  return http.post(`/crm/workbench/transact/${commTaskId}`, data);
};

/**
 * 修改办理后的CRM流程任务
 * @param { string } stageTaskId
 * @param data
 */
export const editProcessTask = (stageTaskId: string, data: any) => {
  return http.post(`/crm/build/task/updateTaskData/${stageTaskId}`, data);
};
